package cn.com.haopy.yue.ai.db.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by xyc on 2020/7/1.
 */
public class GeneratorUtil {

    private static AtomicInteger orderIdCount = new AtomicInteger();

    private static final SimpleDateFormat ORDER_ID_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");


    public static String genOrderSn() {
        int i = orderIdCount.incrementAndGet() % 10000;
        if (i < 10000)
            i += 10000;
        return ORDER_ID_FORMAT.format(new Date()) + i;
    }

}
